//
//  UILabel + Extension.swift
//  WHYWeibo-1.0
//
//  Created by 王洪运 on 15/11/22.
//  Copyright © 2015年 王洪运. All rights reserved.
//

import UIKit

extension UILabel {
    /// 便利构造函数
    ///
    /// - parameter title:      标题
    /// - parameter titleColor: 颜色，默认深灰色
    /// - parameter fontSize:   标题文字大小,默认14号
    ///
    /// - returns: UILabel
    convenience init (title: String, titleColor: UIColor = UIColor.darkGrayColor(), fontSize: CGFloat = 14, screenInset: CGFloat = 0) {
        self.init()

        text = title
        textColor = titleColor
        font = UIFont.systemFontOfSize(fontSize)
        numberOfLines = 0
        
        if screenInset > 0 {
            textAlignment = .Left
            preferredMaxLayoutWidth = UIScreen.mainScreen().bounds.size.width - 2 * screenInset
        }else {
            textAlignment = .Center
        }

    }
    
}
